<?php
/**
 * 数据库类
 *
 * @copyright	http://www.easymvc.com
 * @author 		光哥  <439884988@qq.com>
 * @version		1.0 - 2012-03-26
 * @package		Lib
 */
if(!defined('EASYMVC')) {
	exit('Access Denied');
}
/**
 * 处理pdo类
 */
class Lib_Db_PdoMysql{
	protected static $PDO;
	
	/**
	 * 连接数据库
	 * @param string $host
	 * @param string $port
	 * @param string $name
	 * @param string $user
	 * @param string $pass
	 * @param integer $pconnect
	 * @throws Frame_Exception_Program
	 */
	public static function connect($host,$port,$name,$user,$pass,$pconnect){
		$dsn = "mysql:host={$host};port={$port};dbname={$name}";

		$driver_options[PDO::ATTR_TIMEOUT] = 1;
		
		if($pconnect) $driver_options[PDO::ATTR_PERSISTENT] = true;
		$driver_options[PDO::MYSQL_ATTR_INIT_COMMAND] =  'SET NAMES \'UTF8\'';
		try{
			self::$PDO = new PDO($dsn, $user, $pass, $driver_options);
		}catch(PDOException $e){
		}
		
		try{
			self::$PDO = new PDO($dsn, $user, $pass, $driver_options);
		}catch(PDOException $e){
			throw new Frame_Exception_Program($e->getMessage());
		}
	}
	/**
	 * 魔法函数处理
	 * @param string $func
	 * @param array $args
	 */
	public function __call($func, $args) {
            return call_user_func_array(array(&self::$PDO, $func), $args);
    }
 
}


?>